try:
    # 尝试除以 0（会报错）
    result = 10 / 0
except ZeroDivisionError:
    print("Error: Cannot divide by zero!")
finally:
    print("This always runs, even if there's an error.")

# 自定义异常
class MyError(Exception):
    pass

try:
    raise MyError("Something went wrong!")
except MyError as e:
    print(f"Caught an error: {e}")